package com.hsq.commons.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;


public class BeanFactory implements ApplicationContextAware {
	
		private static ApplicationContext applicationContext;
		
		public void setApplicationContext(ApplicationContext applicationContext)
				throws BeansException {
			BeanFactory.applicationContext=applicationContext;
		}
		public static<T> T getBean(String beanName,Class<T> clasz){
			return (clasz.cast(applicationContext.getBean(beanName)));
		}
		public static Object getBean(String beanName){
			return applicationContext.getBean(beanName);
		}
		

	
		
	}
